<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

    <h2>Logon</h2>

	        <h3 style="color:Red"><%=ViewData["StatusMessage"] %></h3>
	        <% using (Html.BeginForm("DoLogin", "Home", FormMethod.Get, new { name = "LogonForm", id = "LogonForm" }))
            { %>
						<label id="label1" for="UserName">User Name:</label>
						<input type="text" name="UserName" maxlength="50" />
                        <br />
                        <label id="label2" for="secretKey">Password:</label>
                        <input type="password" id="secretKey" name="secretKey" maxlength="100" />
                        <input type="hidden" name="hashedKey" id="hashedKey" />
                        <input type="submit" value="Login" name="submit1" onclick="return RunForm();" />		
   <%} %>
   
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadHolder" runat="server">

   <script src="<%=Url.Content("~/js/sha2.js")%>"  type="text/javascript"></script>
	<script language="javascript" type="text/javascript">

	    function ConvertSha() {
	        var obj = document.getElementById("secretKey");
	        var obj2 = document.getElementById("hashedKey");
	        var salt = '<%=Session["SaltString"] %>';
	        var pass = hex_sha256(obj.value);
	        obj2.value = hex_sha256(pass + ":" + salt);
	        obj.value = "";
	        return true;
	    }
	    function RunForm() {
	        try {
	            if (ConvertSha()) {
	                //$("#LogonForm").submit();
	                return true;
	            } else {
	                alert("Why False?");
	            }
	        } catch (e) {
	            alert("error:" + e.message);
	        }
	        return false;
	    }
	
	</script>
</asp:Content>
